/**
 * 游戏常量定义
 * 统一管理所有游戏中使用的常量，提高代码可维护性
 */

// 游戏基础常量
export const GAME_CONSTANTS = {
    // 基础尺寸
    TILE_SIZE: 32,
    SPRITE_SIZE: 32,
    
    // 游戏速度
    PLAYER_SPEED: 3,
    MONSTER_SPEED: 1,
    
    // FPS相关
    TARGET_FPS: 60,
    FRAME_TIME: 1000 / 60,
    
    // 游戏界面
    UI_Z_INDEX: 100,
    PANEL_Z_INDEX: 200,
    NOTIFICATION_Z_INDEX: 10000,
    
    // 战斗相关
    COMBAT_RANGE: 32,
    PICKUP_RANGE: 32,
    PORTAL_TRIGGER_RANGE: 2,
    MONSTER_CHASE_RANGE: 150,
    SKILL_RANGE: 200,
    
    // 生成相关
    MAX_MONSTERS_PER_MAP: 20,
    MAX_ITEMS_ON_GROUND: 50,
    INVENTORY_SIZE: 20,
    MAX_RINGS: 2,
    
    // 动画相关
    ANIMATION_SPEED: 150,
    NOTIFICATION_DURATION: 2000,
    COMBAT_COOLDOWN: 1000,
    
    // 自动功能阈值
    AUTO_POTION_THRESHOLD: 0.3,
    AUTO_EQUIP_ENABLED: true,
    
    // 掉落率
    BASE_DROP_RATE: 0.8,
    ITEM_DROP_VARIANCE: 0.2
};

// 方向常量
export const DIRECTIONS = {
    DOWN: 0,
    LEFT: 1,
    RIGHT: 2,
    UP: 3
};

// 物品类型常量
export const ITEM_TYPES = {
    WEAPON: 'weapon',
    ARMOR: 'armor',
    ACCESSORY: 'accessory',
    POTION: 'potion',
    CONSUMABLE: 'consumable'
};

// 怪物类型常量
export const MONSTER_TYPES = {
    SLIME: 'SLIME',
    SKELETON: 'SKELETON',
    ORC: 'ORC',
    DRAGON: 'DRAGON',
    PHOENIX: 'PHOENIX'
};

// 技能类型常量
export const SKILL_TYPES = {
    HEAL: 'heal',
    FIREBALL: 'fireball',
    LIGHTNING: 'lightning'
};

// 地图类型常量
export const MAP_TYPES = {
    FOREST_1: 'forest_1',
    FOREST_2: 'forest_2',
    CAVE_1: 'cave_1',
    CAVE_2: 'cave_2',
    MOUNTAIN_1: 'mountain_1',
    VOLCANO_1: 'volcano_1'
};

// 稀有度常量
export const RARITY_TYPES = {
    COMMON: 'common',
    UNCOMMON: 'uncommon',
    RARE: 'rare',
    EPIC: 'epic',
    LEGENDARY: 'legendary'
};

// 颜色常量
export const COLORS = {
    // UI颜色
    PRIMARY: '#4a90e2',
    SUCCESS: '#4CAF50',
    WARNING: '#FF9800',
    DANGER: '#FF5722',
    INFO: '#2196F3',
    
    // 状态栏颜色
    HEALTH: '#ff4d4d',
    MANA: '#4a90e2',
    EXP: '#33ff33',
    
    // 稀有度颜色
    RARITY_COMMON: '#ffffff',
    RARITY_UNCOMMON: '#1eff00',
    RARITY_RARE: '#0070dd',
    RARITY_EPIC: '#a335ee',
    RARITY_LEGENDARY: '#ff8000',
    
    // 怪物颜色
    MONSTER_SLIME: '#4CAF50',
    MONSTER_SKELETON: '#9E9E9E',
    MONSTER_ORC: '#795548',
    MONSTER_DRAGON: '#FF5722',
    MONSTER_PHOENIX: '#FF9800',
    
    // 地图颜色
    MAP_GRASS: '#4CAF50',
    MAP_TREE: '#2E7D32',
    MAP_WATER: '#2196F3',
    MAP_ROCK: '#795548',
    MAP_STONE: '#424242',
    MAP_WALL: '#212121',
    MAP_CRYSTAL: '#9C27B0',
    MAP_LAVA: '#FF5722'
};

// 键盘映射常量
export const KEY_BINDINGS = {
    // 移动
    MOVE_UP: ['w', 'W', 'ArrowUp'],
    MOVE_DOWN: ['s', 'S', 'ArrowDown'],
    MOVE_LEFT: ['a', 'A', 'ArrowLeft'],
    MOVE_RIGHT: ['d', 'D', 'ArrowRight'],
    
    // UI
    TOGGLE_INVENTORY: ['i', 'I'],
    TOGGLE_CHARACTER: ['c', 'C'],
    TOGGLE_SKILLS: ['s', 'S'],
    TOGGLE_MAP: ['m', 'M'],
    CLOSE_PANELS: ['Escape'],
    
    // 技能
    SKILL_1: ['1'],
    SKILL_2: ['2'],
    SKILL_3: ['3'],
    SKILL_4: ['4'],
    SKILL_5: ['5']
};

// 错误消息常量
export const ERROR_MESSAGES = {
    MAP_NOT_FOUND: '地图不存在',
    SKILL_ON_COOLDOWN: '技能冷却中',
    INSUFFICIENT_MANA: '魔法值不足',
    INVENTORY_FULL: '背包已满',
    LEVEL_TOO_LOW: '等级不足',
    INVALID_TARGET: '无效目标',
    ITEM_NOT_FOUND: '物品不存在'
};

// 成功消息常量
export const SUCCESS_MESSAGES = {
    LEVEL_UP: '升级了！',
    ITEM_EQUIPPED: '装备成功',
    ITEM_PICKED_UP: '拾取成功',
    SKILL_LEARNED: '学会新技能',
    MAP_CHANGED: '传送成功'
};

// 默认游戏状态
export const DEFAULT_GAME_STATE = {
    player: {
        x: 100,
        y: 100,
        level: 1,
        exp: 0,
        maxExp: 100,
        health: 100,
        maxHealth: 100,
        mana: 100,
        maxMana: 100,
        damage: 10,
        defense: 5,
        speed: 3,
        inventory: [],
        equipment: {
            weapon: null,
            chest: null,
            rings: []
        },
        direction: DIRECTIONS.DOWN,
        moving: false,
        inCombat: false,
        skills: {
            heal: { 
                name: '治疗术', 
                damage: 0, 
                healing: 30, 
                mana: 15, 
                maxCooldown: 120, 
                cooldown: 0 
            },
            fireball: { 
                name: '火球术', 
                damage: 25, 
                healing: 0, 
                mana: 20, 
                maxCooldown: 60, 
                cooldown: 0 
            },
            lightning: { 
                name: '闪电术', 
                damage: 35, 
                healing: 0, 
                mana: 25, 
                maxCooldown: 90, 
                cooldown: 0 
            }
        }
    },
    monsters: [],
    items: [],
    currentMap: null,
    camera: { x: 0, y: 0 },
    settings: {
        autoPotion: true,
        autoPotionThreshold: 0.3,
        autoEquip: true
    }
};

